package com.msite.service.rabbitmq;

import com.alibaba.fastjson.JSONObject;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.core.MessageListener;

import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.ObjectInputStream;

/**
 * Created by tpeng on 2015/12/31.
 */
public class ContentReceive implements MessageListener {

    @Override
    public void onMessage(Message message) {
        try {
            ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(message.getBody()));
            Object object = ois.readObject();
            System.out.println(JSONObject.toJSON(object));
        } catch (IOException e) {
            e.printStackTrace();
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
        //@todo  ois.readObject();
    }

}
